package br.com.fiap.agenteDialogo.BLL;

import br.com.fiap.agenteDialogo.Beans.Edge;
import br.com.fiap.agenteDialogo.Beans.Vertex;
import edu.uci.ics.jung.graph.DelegateForest;
import edu.uci.ics.jung.graph.DirectedGraph;

public class TreeBuilder
{
    DelegateForest<Vertex,Edge> mTree;
    
    public TreeBuilder(DirectedGraph<Vertex, Edge> graph)
    {
        mTree = new DelegateForest<Vertex, Edge>();
        
        for (Vertex n : graph.getVertices())
        {
            mTree.addVertex(n);
        }
        
        for (Edge e : graph.getEdges())
        {	
            mTree.addEdge(e, graph.getEndpoints(e).getFirst(), graph.getEndpoints(e).getSecond());
        }
    }

    public DelegateForest<Vertex, Edge> getTree()
    {
        return mTree;
    }
}
